using STHPMS1.ICore.I_Common;
using STHPMS1.ICore.I_UI;
using STHPMS1.ICore;
using STHPMS1.ICore.I_Core;

namespace STHPMS1.Web.W_Core
{
	/// <summary>
	/// ui层对象统一调用处
	/// </summary>
	public class UIFacade : DisposeObject, IUIFacade
	{
		private IUIFactory _factory;

		public IUIFactory Factory {
			get {
				IUIFactory factory = null;
				if (Scene == null) {
					factory = MyApp.Locator.GetInstance<IUIFactory> (TypeStringDefinition.UIFACTORY);
				}
				else {
					if (_factory == null)
						_factory = MyApp.Locator.GetInstance<IUIFactory> ();
					factory = _factory;
				}
				System.Diagnostics.Debug.Assert (factory != null, "IUIFactory is null");
				return factory;
			}
		}

		public IScene Scene {
			get;
			set;
		}

		protected override void OnDispose ()
		{
			Factory.Dispose ();
			_factory = null;
		}
	}
}
